package models

import (
	"time"
)

type Comment struct {
	Id      int
	Uuid    string `orm:"unique;index;size(32)"` //唯一uuid
	Content string `orm:"size(4096)"`

	CreateAt time.Time `orm:"auto_now_add;type(datetime)"` //创建时设置为当前时间
	UpdateAt time.Time `orm:"auto_now;type(datetime)"`     //创建更新设置为当前时间

	Flag   int
	RelId  string `orm:size(32); `
	UserId string `orm:size(32); index `
	Nick   string `orm:"size(128)" ` //昵称
	Himg   string `orm:"size(256)" ` //头像地址

	//User      *User       `orm:"rel(fk)"`
	//Upvotes   []*Upvote   `orm:"rel(m2m)"`
	//Resources []*Resource `orm:"reverse(many)"`
	//Binders   []*Binder   `orm:"reverse(many)"`
}

func (p *Comment) TableIndex() [][]string {
	return [][]string{
		[]string{"Flag", "RelId"},
	}
}

type Upvote struct {
	Id       int
	CreateAt time.Time `orm:"auto_now_add;type(datetime)"`

	Flag   int
	RelId  string `orm:size(32); `
	UserId string `orm:size(32); index`

	//User *User `orm:"rel(fk)"`
	//Resources []*Resource `orm:"reverse(many)"`
	//Binders   []*Binder   `orm:"reverse(many)"`
	//Comments  []*Comment  `orm:"reverse(many)"`
}

func (p *Upvote) TableIndex() [][]string {
	return [][]string{
		[]string{"Flag", "RelId"},
	}
}
